<?php
function by_transaction(){
	if(!isset($_GET['date_i_y']) && !isset($_GET['date_i_m']) && !isset($_GET['date_i_d']) && !isset($_GET['date_i_h'])&& !isset($_GET['date_i_min'])){
		$time_in = date("Y")."-".date("n")."-".date("j")." 00:00:00";
	}else{
		$time_in = $_GET['date_i_y']."-".$_GET['date_i_m']."-".$_GET['date_i_d']." ".$_GET['date_i_h'].":".$_GET['date_i_min'].":00";
	}
	if(!isset($_GET['date_o_y']) && !isset($_GET['date_o_m']) && !isset($_GET['date_o_d']) && !isset($_GET['date_o_h'])&& !isset($_GET['date_o_min'])){
		$time_out = date("Y")."-".date("n")."-".date("j")." 23:59:59";
	}else{
		$time_out = $_GET['date_o_y']."-".$_GET['date_o_m']."-".$_GET['date_o_d']." ".$_GET['date_o_h'].":".$_GET['date_o_min'].":59";
	}
	$sql="select clients.firstname, historique.transaction,historique.date,historique.m_pay from historique RIGHT JOIN clients ON historique.client = clients.id ";
?>
	<table>
		
	</table>
	<p>Total :</p>
	<p>Total de client :</p>
	<p>Total d'offre :</p>
		<form>
			<table>
				<tr><td>Du</td><td><input type="text" size="1" MAXLENGTH="2" name="date_i_d" /> / <input type="text" size="1" MAXLENGTH="2" name="date_i_m" /> / <input type="text" size="2" MAXLENGTH="4" name="date_i_y" value="<?php print date("Y");?>"/></td><td>A</td><td><input type="text" name="date_i_h" size="1" MAXLENGTH="2" />:<input type="text" name="date_i_min" size="1" MAXLENGTH="2" /></td><td>Au</td><td><input type="text" size="1" MAXLENGTH="2" name="date_o_d" value="<?php print date("j");?>"/> / <input type="text" size="1" MAXLENGTH="2" name="date_o_m" value="<?php print date("n");?>" /> / <input type="text" size="2" MAXLENGTH="4" name="date_o_y" value="<?php print date("Y");?>"/></td><td>A</td><td><input type="text" name="date_o_h" size="1" MAXLENGTH="2" value="<?php print date("H");?>"/>:<input type="text" name="date_o_min" size="1" MAXLENGTH="2" value="<?php print date("i");?>" /></td><td><input type="submit" value="Afficher l'historique" /></td></tr>
			</table>
		</form>
<?php
}
function by_day(){
?>
		<table>
		
		</table>
			<p>Total :</p>
			<p>Total de client :</p>
			<p>Total d'offre :</p>
		<form>
			<table>
				<tr><td>Du</td><td><input type="text" size="1" MAXLENGTH="2" name="date_i_d" /> / <input type="text" size="1" MAXLENGTH="2" name="date_i_m" /> / <input type="text" size="2" MAXLENGTH="4" name="date_i_y" value="<?php print date("Y");?>"/></td><td>Au</td><td><input type="text" size="1" MAXLENGTH="2" name="date_o_d" value="<?php print date("j");?>"/> / <input type="text" size="1" MAXLENGTH="2" name="date_o_m" value="<?php print date("n");?>" /> / <input type="text" size="2" MAXLENGTH="4" name="date_o_y" value="<?php print date("Y");?>"/></td><td><input type="submit" value="Afficher l'historique" /></td></tr>
			</table>
		</form>
<?php
}
function by_month(){
?>
		<table>
		
		</table>
			<p>Total :</p>
			<p>Total de clients :</p>
			<p>Total d'offres vendues:</p>
		<form>
			<table>
				<tr><td>Du</td><td><input type="text" size="1" MAXLENGTH="2" name="date_i_d" /> / <input type="text" size="1" MAXLENGTH="2" name="date_i_m" /> / <input type="text" size="2" MAXLENGTH="4" name="date_i_y" value="<?php print date("Y");?>"/></td><td>Au</td><td><input type="text" size="1" MAXLENGTH="2" name="date_o_d" value="<?php print date("j");?>"/> / <input type="text" size="1" MAXLENGTH="2" name="date_o_m" value="<?php print date("n");?>" /> / <input type="text" size="2" MAXLENGTH="4" name="date_o_y" value="<?php print date("Y");?>"/></td><td><input type="submit" value="Afficher l'historique" /></td></tr>
			</table>
		</form>
<?php
}

?>
<p><a href="?page=bilan">Par transaction</a> <a href="?page=blian&onglet=byday" >Par jour</a> <a href="?page=blian&onglet=bymonth" >Par mois</a></p>
<?php 
if(!isset($_GET['onglet'])){
	by_transaction();
}else{
	if($_GET['onglet']=="bytransaction"){
		by_transaction();
	}elseif($_GET['onglet']=="byday"){
		by_day();
	}elseif($_GET['onglet']=="bymonth"){
		by_month();
	}
}